﻿using System;

namespace Ndmx.Framework.Common
{
    public class Factory
    {
        private Type type;
        private String prefix;

        public Factory(Type type, String prefix)
        {
            this.type = type;
            this.prefix = prefix;
        }

        public Object create(String entityName, String objectNamespace)
        {
            String typeName = objectNamespace + "." + prefix + entityName;
            Type type = Type.GetType(typeName);
            if (type == null) type = this.type;

            Object o = null;
            try
            {
                o = Activator.CreateInstance(type);
            }
            catch
            {
                //
            }
            return o;

        }
    }
}
